﻿@model FCDB.Entity.FormRebate
@using FB.Extensions;
@{
    ViewBag.Title = "担保返佣单审批表";
    Layout = "~/Views/Shared/_FormLayout.cshtml";
    var IsViewMode = Model.Status != (short)FCDB.Entity.FormStatusEnum.Empty && Model.Status != (short)FCDB.Entity.FormStatusEnum.Draft;    
    
}
@section HeadIncluder 
{
    <link href='@Url.Content("~/Content/public.css")' rel="stylesheet" />
    <link href='@Url.Content("~/Content/con_style.css")' rel="stylesheet" /> 
}
 @{
     Html.RenderPartial("UCFormButtonBar", Model);
        }
    <div class="frombox" id="formMain">
        <div class="from_l" style="background: #fff;">
            <div class="left_con_f PrintArea">
                 
                <div align="center" class="left_f_tit">担保返佣单审批表</div>
               @using (Html.BeginForm("SaveFormRebate", "Form", FormMethod.Post, new { id = "frm" }))
               {
                   Html.RenderPartial("UCHiddenArea"); 
                  <table width="100%" class="left_xx">
                        <tr>
                            <td class="text_w" align="center">流程名称：
                            </td>
                            <td colspan="5">
                                 @if (IsViewMode)
                                 {
                                    @Model.FormTitle
                                 }
                                 else
                                 {
                                <input id="txtFormTitle" style="width:98%;"  class="validate[required] in_c1 " type="text"    name="FormTitle" value="@Model.FormTitle"/>
                                 }
                            </td>
                        </tr>
                       <tr >
                           <td class="text_w" align="center">审批序号</td>
                           <td  colspan="2">
                                @if (IsViewMode)
                                {
                                    @Model.FormNumber
                                }
                                else
                                {
                               <input   type="text"   id="FormNumber" style="width:100px;"  readonly="readonly" class="in_c1" value="@Model.FormNumber" name="FormNumber"   />
                                }
                           </td>
                           <td  class="text_w" align="center">日期
                           </td>
                           <td colspan="2">
                               @if (IsViewMode)
                               {
                                   @Model.FormDate.Value.ToString("yyyy-MM-dd")
                               }
                               else
                               {
                                   <input type="text" id="FormDate" class="in_c1" value="@Model.FormDate.Value.ToString("yyyy-MM-dd")" name="FormDate" />
                               }
                           </td>

                       </tr>
                      <tr>
                          <td class="text_w" align="center">关联表单</td>
                          <td colspan="5">
                              @if (IsViewMode)
                              {
                                  @ViewBag.FCDBName
                              }
                              else
                              {
                                  <input type="text" id="FCDBName" style="width:80%;" readonly="readonly" class="in_c1" value="@ViewBag.FCDBName" name="FCDBName" />
                                  <input id="FormCDBID" type="hidden" name="FormCDBID" value="@Model.FormCDBID" /> 
                                    <button type="button" onclick="AddFormsFCDB()" class="fj btn_c3 btn_s" style="display:inline">添加表单</button>
                              }
                          </td>

                      </tr>

                       <tr >
                           <td class="text_w" align="center">申请部门</td>
                           <td colspan="2">
                                @if (IsViewMode)
                                {
                                    @ViewBag.DepartmentName
                                }
                                else
                                {
                               <input type="text"    disabled="disabled" style="width:100px" id="DepartmentName"  class="in_c1" value="@ViewBag.DepartmentName"  name="DepartmentName"  />
                                 <input id="DepartmentID" type="hidden" name="DepartmentID" value="@Model.DepartmentID" />
                                }
                           </td>
                           <td class="text_w" align="center">申请人</td>
                           <td colspan="2">
                               @if (IsViewMode)
                               {
                                   @ViewBag.UserName
                               }
                               else
                               {
                                   <input type="text" class="in_c1" style="width:100px" disabled="disabled" id="UserName" name="UserName" value="@ViewBag.UserName" />
                                   <input id="ApplyUserID" type="hidden" name="ApplyUserID" value="@Model.ApplyUserID" />
                               }
                           </td>

                          
                       </tr>
                      
                   </table>
               }
                <form style="display:none" action="@Url.Action("SaveFormRebateBillDue", "Form")" id="frmOTInfoConfirm">
                    <input type="hidden" name="ProcessGuid" value='@Request["ProcessGuid"]' />
                    <input type="hidden" name="ID" value="@Model.ID" />
                    <input type="hidden" name="FormGuid" value="@Model.FormGuid" />
                    <input type="hidden" name="Status" value="@Model.Status" />
                    <table style="width:100%;height:36px; border:none;">
                        <tr>
                            <td class="text_w" align="center" style="width: 151px;">
                               04. 出纳</td>
                            <td style="border-bottom: none; border-top: none; border-right: none; ">
                                出纳金额
                                @if (Model.BillDue.HasValue)
                                {
                                    <span> @Html.formatCash(Model.BillDue.Value.ToString()) </span>
                                }
                                else
                                {
                                    <input type="text" id="txtBillDue" name="BillDue" value="@Model.BillDue" />
                                }
                            </td>
                        </tr>
                    </table>
                </form>

            
                @{
                    Html.RenderPartial("UCFormCheckLog");
                }

             </div>
        </div>
        <div class="from_r">
            <div class="right_con_f">
                <div class="f_fj">
                            @{
                                Html.RenderPartial("UCFormAttachment", (IList<FCDB.Entity.FormAttachment>)ViewBag.FormAttachments);
                            }
                </div>
                <div class="f_fj">
                            @{
                                Html.RenderPartial("UCFormsRelation", (IList<FCDB.Entity.FormsRelation>)ViewBag.FormsRelations);
                            }
                      
                </div>
                <div class="xx_yj">
                    <p class="yj_tit">详细意见</p>
                    <div class="con_yj">
                            @{
                                Html.RenderPartial("UCFormCirculatedDocumentLog", (IList<FCDB.Entity.FormCirculatedDocumentLog>)ViewBag.FormCirculatedDocumentLogs);
                            }
                            </div>
                </div>

            </div>
        </div>
    </div>
 
<script src=@Url.Content("/Scripts/jquery.form.js") type="text/javascript"></script>
<script src=@Url.Content("/Scripts/FCDB.form.js?v=20170821") type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#frm").validationEngine({ promptPosition: "topLeft" });
        $("#FormDate").kendoDatePicker({
            format: "yyyy-MM-dd",
            value: new Date()
        });
        upLowWord();

        if ($("#txtDue").val() == "") {
            $("#txtDueUpWord").html(Arabia_to_Chinese("@Model.Due"));
        }

        var kendo = $("#FormDate").data("kendoDatePicker");
        var formStatus = $("#hStatus").val();

        var ProccessActiveContainerList = $(".ProccessActiveContainer");
        if (ProccessActiveContainerList.length > 0) {
            $.each(ProccessActiveContainerList, function (i, item) {
                var divId = $(item).attr("id");
                var frmID = divId.slice(3);
                $("#" + frmID).appendTo(item);
                $("#" + frmID + " select").attr("disabled", "disabled");
                $("#" + frmID + " input").attr("disabled", "disabled");
                $("#" + frmID).show();
            });
            $(".curentContainer form select").removeAttr("disabled");
            $(".curentContainer form input").removeAttr("disabled");
        }
    });
    function upLowWord() {
        var num = Arabia_to_Chinese($("#Due").val());
        $("#txtDueUpWord").html(num);
        var FormTitle = '@Model.FormTitle';
        $("#txtFormTitle").val(FormTitle + "--金额:" + $("#Due").val());
    }


    function Save() {
        var formStatus = $("#hStatus").val();
        if (formStatus == "0" || formStatus == "1") {
            var flag = $('#frm').validationEngine('validate');
            if (!flag) return false;
            GetProcessCheckUser(null, null, function (selectPostList) {
                if (selectPostList != null || selectPostList != undefined) {
                    var arr = new Array();
                    $.each(selectPostList.UserIDList, function (i, item) {
                        var obj = new Object();
                        obj.Key = item.UserID;
                        obj.Value = item.Name;
                        arr.push(obj);
                    });
                    selectPostList.UserIDList = arr;
                    var checkUserList = selectPostList;
                    if (checkUserList == null) return;

                    var FormConditionValue = JSON.stringify(GetFormCondition());
                    var options = {
                        data: {
                            FormAttachement: GetFormAttachement(), FormsRelation: GetFormsRelation(),
                            CheckLogUser: JSON.stringify(checkUserList.UserIDList),
                            NextActivityGuid: checkUserList.ActivityGuid, FormConditionValue: FormConditionValue
                        },
                        success: function (data) {
                            alert("表单发送成功");
                            window.close();
                        }
                    };
                    $("#hStatus").val("2");
                    $("#frm").ajaxSubmit(options);
                }
            });
        }
        else {
            submitCheckLog();
        }
    }
    function SaveAsDraft() {
        var flag = $('#frm').validationEngine('validate');
        var options = {
            data: { FormAttachement: GetFormAttachement(), FormsRelation: GetFormsRelation() },
            success: function (data) {
                alert("保存成功");
                window.close();
            }
        };
            $("#hStatus").val("1");
            $("#frm").ajaxSubmit(options);
        }

    function AddFormsFCDB() {
        var AppInstanceID = $("#hAppInstanceID").val();
        var ProcessGuid = $("#hProcessGuid").val();
        var FormID = $("#hID").val();
        var ActivityGuid = $("#hActivityGuid").val();
        var FormTable = '@ViewContext.RouteData.Values["action"]'
        var url = '@Url.Action("AddFormsFCDB", "Form")' + '?AppInstanceID=' + AppInstanceID + '&ProcessGuid=' + ProcessGuid + "&FormID=" + FormID + "&FormTable=" + FormTable + "&ActivityGuid=" + ActivityGuid;
        window.winObj = window;
        window.refresh = AddFormsFCDBCallBack;
        window.oDG = $.dialog({
            lock: true,
            background: '#FFF',
            opacity: 0.5,
            id: 'esDialog',
            title: "选择表单",
            titleAlign: 'left',
            content: "url:" + url,
            width: 800,
            height: 650,
            btnBar: false,
            lockScroll: true
        });
    }
    function AddFormsFCDBCallBack(arr) {
        $.each(arr, function (i, item) {
            var url = '@Url.Action("ViewProccessInstance", "MyProcessInstance")' + '?AppInstanceID=' + item.AppInstanceID + '&&AppName=' + item.AppName + '&&ProcessGUID=' + item.ProcessGUID;
            $("#FormCDBID").val(item.ID);
            $("#FCDBName").val(item.AppName);
        });
    }
</script>


